# phi auto cmake utils
include(phi)

# paddle experimental common components
add_subdirectory(common)

# phi (low level) api headers: include
# phi (high level) api
add_subdirectory(api)
# phi core components
add_subdirectory(core)
# phi components of specific backends
add_subdirectory(backends)
# phi kernels for diff device
add_subdirectory(kernels)
# phi infermeta
add_subdirectory(infermeta)
# phi tools
add_subdirectory(tools)
# phi tests
add_subdirectory(tests)
# phi capi
if(WITH_CUSTOM_DEVICE)
  add_subdirectory(capi)
endif()

# make an unity target for compile deps
set(PHI_DEPS
    convert_utils
    dense_tensor
    phi_backends
    kernel_factory
    kernel_context
    arg_map_context
    infermeta
    lod_utils
    sparse_csr_tensor
    sparse_coo_tensor
    string_tensor
    api_scalar
    api_int_array
    extended_tensor)

get_property(phi_kernels GLOBAL PROPERTY PHI_KERNELS)
set(PHI_DEPS ${PHI_DEPS} ${phi_kernels})

cc_library(phi DEPS ${PHI_DEPS})

set(phi_extension_header_file
    ${CMAKE_CURRENT_SOURCE_DIR}/extension.h
    CACHE INTERNAL "phi/extension.h file")
file(
  WRITE ${phi_extension_header_file}
  "// Header file generated by paddle/phi/CMakeLists.txt for external users,\n// DO NOT edit or include it within paddle.\n\n#pragma once\n\n"
)

# generate inner headers include dir for users
generate_unify_header(backends)
generate_unify_header(core EXCLUDES cuda_stream.h)
generate_unify_header(infermeta)
generate_unify_header(kernels SKIP_SUFFIX grad_kernel)
